package com.example.mqtt.controller;

import com.example.mqtt.dto.LoginRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class AuthController {
    @CrossOrigin
    @PostMapping("/login")
    public ResponseEntity<?> login(@RequestBody LoginRequest request) {
        if(request.username().equals("admin") && request.password().equals("123456")){
            return ResponseEntity.ok("登录成功");
        }else{
            return ResponseEntity.status(401).body("登录失败");
        }
    }
}